package jp.ne.hatena.d.digitalsoul.warikan.mocks

import jp.ne.hatena.d.digitalsoul.warikan.models._
import jp.ne.hatena.d.digitalsoul.warikan.repositories.impl._

class MockPartyRepositoryImpl extends PartyRepositoryImpl {

	var parties = Map[String, Party]()
	
	override def nextId:String = (parties.size + 1).toString
	
	override def add(party:Party) = parties += (party.id -> party)
	
	override def forPartyId(id:String):Option[Party] = 
		if (parties.contains(id)) Option[Party](parties(id)) else None
	
	override def forAll:List[Party] = parties.values.toList
	
	override def paymentOf(id:String, name:String):Int = { 
		if(parties contains id) parties(id).allots(name).amount else 0
	}
	
	def initialize = parties = Map[String, Party]()
	
}